def main():
    print("=== 欢迎使用ATM系统 ===")
    print("1. 查询余额")
    print("2. 存款")
    print("3. 取款")
    print("其他键退出")
    print("===================")

    choice = input("请选择操作：")
    return choice


# 全局变量，模拟账户余额
balance = 10000


def query(show_detail=False):
    """查询余额"""
    if show_detail:
        print(f"您的账户余额为：{balance}元")
    return balance


def saving(amount):
    """存款功能"""
    global balance
    if amount <= 0:
        print("存款金额必须大于0")
        return False

    balance += amount
    print(f"存款成功！存入：{amount}元")
    print(f"当前余额：{balance}元")
    return True


def get_money(amount):
    """取款功能"""
    global balance
    if amount <= 0:
        print("取款金额必须大于0")
        return False

    if amount > balance:
        print("余额不足！")
        print(f"当前余额：{balance}元")
        return False

    balance -= amount
    print(f"取款成功！取出：{amount}元")
    print(f"当前余额：{balance}元")
    return True
# 没置无限循环，确保程序不退出
while True:
    keyboard_input = main()
    if keyboard_input == "1":
        query(True)
        continue    # 通过continue继续下一次循环，一进来就，
    elif keyboard_input == "2":
        num = int(input("您想要存多少钱？请输入："))
        saving(num)
        continue
    elif keyboard_input == "3":
        num = int(input("您想要取多少钱？请输入："))
        get_money(num)
        continue
    else:
        print("程序退出啦")
        break       # 通过break退出循环